package com.example.javatwo.mapper.cg.yt;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

import com.example.javatwo.pojo.cg.yt.DsDataSet1;
import com.example.javatwo.pojo.cg.yt.DsDataSet2;

@MapperScan
public interface CgqgdMapper {
	// 查询全表
	@Select("select * from dsdataset1   where del='否' order by billNo desc LIMIT ${sum},1 ")
	public List<DsDataSet1> list(@Param("sum") int sum);

	// 总共多少数量
	@Select("select sum(1) from dsdataset1")
	public Integer sum();

	// 更具主表id查询降表
	@Select("select * from dsdataset2 where billno='${billno}'")
	public List<DsDataSet2> list2(@Param("billno") String billno);

	// 添加主表信息
	public void add(@Param("by") DsDataSet1 dataSet1);

	// 添加降表
	public void addInfo(@Param("by") DsDataSet1 dataSet1);

	// 修改主表信息
	public void update(@Param("by") DsDataSet1 dataSet1);
	
	@Delete("delete dsdataset2 where billNo = '${billNo}'")
	public void deleteInfo(@Param("billNo") String billNo);

	// 修改主表删除状态
	@Delete("update dsdataset1 set del = '是' where billNo = '${billno}' ")
	public void delete(@Param("billNo") String billNo);

	// 修改主表的单况状态
	@Update("update dsdataset1 set billStatus = '${billStatus}' where billNo = '${billno}' ")
	public void setbillStatus(@Param("billNo") String billNo, @Param("billStatus") String billStatus);

	// 修改降表的未出库数量
	@Update("update dsdataset2 set qtyRemain = '${qtyRemain}' where serNo = '${serNo}' ")
	public void setQtyRemain(@Param("qtyRemain") String sQuantity, @Param("serNo") Integer serNo);

	// 修改主表的审核状态
	@Update("update dsdataset1 set ynAudit = '${ynAudit}' where billNo = '${billno}',remarks1='n' ")
	public void setYnAudit(@Param("billno") String billNo, @Param("ynAudit") String ynAudit);

	@Select("select ynaudit from dsdataset1 where billno='${billNo}'")
	public String findSet1(@Param("billNo") String billNo);
}
